"""
aula 6
pilha
"""
# -*- coding: utf-8 -*-

class Stack():
	
	def __init__(self, N):
		self.top = -1
		self.S = [0 for k in range(N)]
		pass
		
	def stackEmpty(self):
		if self.top == 0:
			return True
		else:
			return False
		pass

	def pop(self):
		if self.stackEmpty():
			return "underflow"
		else:
			self.top = self.top - 1
			return self.S[self.top + 1]
		pass

	def push(self, x):
		self.top = self.top + 1
		self.S[self.top] = x
		pass
	
	def __str__(self):
		s = ""
		s += str(self.top + 1) + ": "
		for k in range (0, len(self.S)):
			s += "" + str(self.S[k]) + ", "
		return s

	
obj = Stack(10)

print obj.stackEmpty()
obj.push(20)
obj.push(2)
obj.push(6)
print obj
obj.pop()
print obj

obj.push(10)
print obj
